const fs = require('fs');
try {

    fs.open('./input.txt', 'a+', (err, fd)=>{
        if(err) {
            fs.close(fd);
            throw err;
            return false;
        }
        fs.write(fd, '万岁！', (err, bytes, str)=>{
            if(err){
                fs.close(fd);
                throw err;
                return false;
            }
            console.log('写入成功，共写入' + bytes + '字节。');
            fs.close(fd);
            fs.unlink('./temp.txt', err=>{
                if(err) throw err;
                console.log('删除文件成功！');
            })
        });

    });
    
} catch (error) {
    console.log(error);
}